#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>

using namespace std;

struct v2{
	double x, y;
	v2() {}
	v2(double x, double y): x(x), y(y) {}
	v2 operator- (const v2& r) const{
		return v2(x - r.x, y - r.y); }
	double sqlen() const{
		return x * x + y * y; }
	double len() const{
		return sqrt(x * x + y * y);
	}
};

double dot(const v2& l, const v2& r){
	return l.x * r.x + l.y * r.y; }

inline double ang(const v2& a, const v2& b, const v2& c){
	double dt = dot(b - a, c - b) / (b - a).len() / (c - b).len();
	dt = max(-1.0, dt);
	dt = min(1.0, dt);
	return acos(dt);
}

int main(){
	ios_base::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	vector<v2> x(n);
	for (int i = 0; i < n; ++i)
		cin >> x[i].x >> x[i].y;
	vector<vector<int> > g(n);
	for (int i = 0; i < m; ++i){
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	double ans = 0.0;
	for (int i = 0; i < n; ++i){
		vector<int>& v = g[i];
		if (v.size() == 2)
			ans += ang(x[v[0]], x[i], x[v[1]]);
		if (v.size() == 4){
			double mb1 = ang(x[v[0]], x[i], x[v[1]]) + ang(x[v[2]], x[i], x[v[3]]);
			double mb2 = ang(x[v[0]], x[i], x[v[2]]) + ang(x[v[1]], x[i], x[v[3]]);
			double mb3 = ang(x[v[0]], x[i], x[v[3]]) + ang(x[v[2]], x[i], x[v[1]]);
			ans += min(mb1, min(mb2, mb3));
		}
	}
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}